/*
 * 项目名称:platform-plus
 * 类名称:BizLeaveController.java
 * 包名称:com.platform.modules.biz.controller
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2020-07-26 15:59:32        李鹏军     初版做成
 *
 * Copyright (c) 2019-2019 微同软件
 */
package com.platform.modules.biz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.common.annotation.SysLog;
import com.platform.common.utils.RestResponse;
import com.platform.modules.sys.controller.AbstractController;
import com.platform.modules.biz.entity.BizLeaveEntity;
import com.platform.modules.biz.service.BizLeaveService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Controller
 *
 * @author 李鹏军
 * @date 2020-07-26 15:59:32
 */
@RestController
@RequestMapping("biz/leave")
public class BizLeaveController extends AbstractController {
    @Autowired
    private BizLeaveService bizLeaveService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("biz:leave:list")
    public RestResponse queryAll(@RequestParam Map<String, Object> params) {
        List<BizLeaveEntity> list = bizLeaveService.queryAll(params);

        return RestResponse.success().put("list", list);
    }

    /**
     * 分页查询
     *
     * @param params 查询参数
     * @return RestResponse
     */
    @GetMapping("/list")
    @RequiresPermissions("biz:leave:list")
    public RestResponse list(@RequestParam Map<String, Object> params) {
        Page page = bizLeaveService.queryPage(params);

        return RestResponse.success().put("page", page);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return RestResponse
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("biz:leave:info")
    public RestResponse info(@PathVariable("id") Long id) {
        BizLeaveEntity bizLeave = bizLeaveService.getById(id);

        return RestResponse.success().put("leave", bizLeave);
    }

    /**
     * 新增
     *
     * @param bizLeave bizLeave
     * @return RestResponse
     */
    @SysLog("新增")
    @RequestMapping("/save")
    @RequiresPermissions("biz:leave:save")
    public RestResponse save(@RequestBody BizLeaveEntity bizLeave) {

        bizLeaveService.add(bizLeave);

        return RestResponse.success();
    }

    /**
     * 修改
     *
     * @param bizLeave bizLeave
     * @return RestResponse
     */
    @SysLog("修改")
    @RequestMapping("/update")
    @RequiresPermissions("biz:leave:update")
    public RestResponse update(@RequestBody BizLeaveEntity bizLeave) {

        bizLeaveService.update(bizLeave);

        return RestResponse.success();
    }

    /**
     * 根据主键删除
     *
     * @param ids ids
     * @return RestResponse
     */
    @SysLog("删除")
    @RequestMapping("/delete")
    @RequiresPermissions("biz:leave:delete")
    public RestResponse delete(@RequestBody Long[] ids) {
        bizLeaveService.deleteBatch(ids);

        return RestResponse.success();
    }
}
